if
and else
¶
🎨 if
¶
red_dots.py
¶
Turn the red dots into blue dots.
🎨 else
¶
more_red_dots.py
¶
Turn the red into blue and the white spaces into green.
🎨 elif
¶
turns.py
¶
- While Bit is not blocked, move forward
- If the square is red, turn left
- Otherwise, if the square is green, turn right
- Otherwise, paint the square blue
Holes 👩🏼🎨¶
holes.py
¶
Bit is in the pipes, and the pipes have holes. Bit's job is to mark where the holes are so someone else can fix them.
- Mark holes on the right with red
- Mark holes on the left with green
- Otherwise paint blue
Fly 👩🏾🎨¶
fly.py
¶
Bit is out flying around.
When Bit finds a blue square, he turns left.
When Bit finds a green square, he turns right.
When Bit finds a red square, he stops.
Elevators 👨🏼🎨¶
More Elevators¶
Now write a single function that can allow Bit to travel in either direction.
Key Ideas¶
if
,else
, andelif
- event stream pattern:
- handle specific events that come up while moving towards a goal
- outer
while
with innerif
- outer
- handle specific events that come up while moving towards a goal
- Boundary conditions